package com.itboye.lottery.utils;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.itboye.lottery.BuildConfig;
import com.itboye.lottery.alert.ByAlert;
import com.itboye.lottery.app.MyApplication;

import static com.itboye.lottery.utils.SPUtils.getSp;

public class Utils {
    public static String getVersion() {
        int appVersion = 0;
        try {

            PackageManager pm = MyApplication.Companion.getInstance()
                    .getPackageManager();
            PackageInfo info = pm.getPackageInfo(MyApplication.Companion.getInstance()
                    .getPackageName(), 0);
            appVersion = info.versionCode;
        } catch (Exception e) {

        }
        return "" + appVersion;
//        return "" + 100;
    }

    public static boolean emptyMsgShow(String comareMsg, String msg) {
        if (comareMsg == null || "".equals(comareMsg)) {
            ByAlert.alert("请输入" + msg);
            return false;
        }
        return true;
    }

    public static String getToken() {
        if (BuildConfig.IS_DEBUG) {
//            return getSp(Const.Companion.getTOKEN()) + "";
//            return "e1525361a9d2aebf6ad443399a9b6d673039649a";//ttgc dk token
//            return "a6f0cdf6e8c6142f7da3d1d8fa6a7f09492c3d33";//yuncai_prod dk token
//            return "532b58b77a1b460fb62784198a19f74164cfa5e8";//yuncai_prod lxf token
//            return "a65a192a51443ee764c315a1326a75d33c3968fa";//yuncai_pro wzy token
//            return "a66186c6c06d8ecc8f5185364d3f46400dc37dcf";
            return "e31845aec1dee81581c7b8f5ae2af3def42b2c2d";
        } else {
            return getSp(Const.Companion.getTOKEN()) + "";
        }
//        return getSp(Const.Companion.getTOKEN()) + "";
    }

    //创建复制内容到系统剪贴板
    public static void clip(String content) {
        //获取剪贴板管理器：
        ClipboardManager cm = (ClipboardManager) MyApplication.Companion.getInstance().getSystemService(Context.CLIPBOARD_SERVICE);
        // 创建普通字符型ClipData
        ClipData mClipData = ClipData.newPlainText("Label", content);                // 将ClipData内容放到系统剪贴板里。
        cm.setPrimaryClip(mClipData);

    }
}
